package com.example.content.fragment.me.coin

import androidx.fragment.app.Fragment
import com.example.content.ME_CASH_OUT_TYPE
import com.example.content.ME_CHARGE_COIN_TYPE
import com.example.content.R
import com.example.content.adapter.viewpager.HomePagerAdapter
import com.example.content.databinding.MyCoinLayoutBinding
import com.example.content.fragment.BaseMvvmFragment
import com.example.content.manager.ActivityMgr
import com.example.content.viewmodule.me.MyPageCommonViewModel

/**
 * Created by zhudongao
 * Desc
 * Date 2020/11/8
 */
class MyCoinFragment : BaseMvvmFragment<MyCoinLayoutBinding, MyPageCommonViewModel>() {

    private lateinit var tabTitles:Array<String>
    private val fragments = mutableListOf<Fragment>()

    override fun initView() {
        dataBinding.titleBar.title.text = getString(R.string.my_coin)
        tabTitles = resources.getStringArray(R.array.slide_tab)
        tabTitles.forEach { _ ->
            fragments.add(ChargeListFragment())
        }
        dataBinding.viewPager.adapter = HomePagerAdapter(childFragmentManager, fragments, tabTitles)
        dataBinding.slidingTab.setViewPager(dataBinding.viewPager, tabTitles)
    }

    override fun initListener() {
        super.initListener()
        dataBinding.titleBar.backIcon.setOnClickListener {
            activity?.finish()
        }
        dataBinding.charge.setOnClickListener {
            ActivityMgr.startFragment(ME_CHARGE_COIN_TYPE)
        }
        dataBinding.cashOut.setOnClickListener {
//            ActivityMgr.startFragment(ME_CASH_OUT_TYPE)
        }
    }

    override fun getLayoutId() = R.layout.my_coin_layout

    companion object {
        fun newInstance() = MyCoinFragment()
    }

    override fun getViewModuleClass(): Class<MyPageCommonViewModel> {
        return MyPageCommonViewModel::class.java
    }
}